﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes.inventory {
    import flash.utils.*;

    public class RequestInventoryComponent {

        private var m_inventories:Dictionary;

        public function RequestInventoryComponent(){
            this.m_inventories = new Dictionary();
        }
        public function loadObject(_arg1:Object):void{
            var _local2:String;
            var _local3:BaseInventory;
            if (_arg1 != null){
                for (_local2 in _arg1["m_inventories"]) {
                    _local3 = new BaseItemInventory(_arg1["m_inventories"][_local2]);
                    this.m_inventories[_local2] = _local3;
                };
            };
        }
        public function create(_arg1:String):BaseInventory{
            var _local2:BaseInventory = new BaseItemInventory(null);
            this.m_inventories[_arg1] = _local2;
            return (_local2);
        }
        public function remove(_arg1:String):void{
            delete this.m_inventories[_arg1];
        }
        public function get(_arg1:String):BaseInventory{
            return ((this.m_inventories[_arg1] as BaseInventory));
        }
        public function addItem(_arg1:String, _arg2:int, _arg3:String):Boolean{
            var _local4:BaseInventory = this.get(_arg3);
            if (_local4 == null){
                _local4 = this.create(_arg3);
            };
            return (_local4.add(_arg1, _arg2));
        }
        public function removeItem(_arg1:String, _arg2:int, _arg3:String):Boolean{
            var _local4:Boolean;
            var _local5:BaseInventory = this.get(_arg3);
            if (_local5 != null){
                _local4 = _local5.remove(_arg1, _arg2);
                if (_local5.getTotalCount() == 0){
                    this.remove(_arg3);
                };
            };
            return (_local4);
        }
        public function getItemCount(_arg1:String, _arg2:String):int{
            var _local3:int;
            var _local4:BaseInventory = this.get(_arg2);
            if (_local4 != null){
                _local3 = _local4.getCount(_arg1);
            };
            return (_local3);
        }

    }
}//package Classes.inventory 
